package com.zy.ivideo.controller;

import com.zy.ivideo.entity.FocuseEntity;
import com.zy.ivideo.entity.ResponseEntity;
import com.zy.ivideo.service.FocuseService;
import com.zy.ivideo.token.UserToken;
import com.zy.ivideo.utils.ResponseUtils;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/focuse")
@Api(value = "关注模块API接口", description = "该模块提供关注模块服务", tags = "关注模块")
public class FocuseController {
    @Autowired
    FocuseService service;

    /**
     * 关注
     * @param focuseUserid
     * @param focusedUserid
     * @return
     */
    @UserToken
    @ApiOperation(value = "关注", notes = "关注", httpMethod = "POST")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(dataType = "long", name = "focuseUserid", value = "关注者id", required = true),
            @ApiImplicitParam(dataType = "long", name = "focusedUserid", value = "被关注者id", required = true)
    })
    @PostMapping("/focuse")
    public ResponseEntity<FocuseEntity> focuse(long focuseUserid,long focusedUserid){
        return service.focuse(focuseUserid,focusedUserid);
    }

    /**
     * 取消关注
     * @param focuseUserid
     * @param focusedUserid
     * @return
     */
    @UserToken
    @ApiOperation(value = "取消关注", notes = "取消关注", httpMethod = "DELETE")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(dataType = "long", name = "focuseUserid", value = "关注者id", required = true),
            @ApiImplicitParam(dataType = "long", name = "focusedUserid", value = "被关注者id", required = true)
    })
    @DeleteMapping("/unFocuse")
    public ResponseEntity<Boolean> unFocuse(long focuseUserid,long focusedUserid){
        return service.unFocuse(focuseUserid,focusedUserid);

    }
}
